import request from '@/utils/request.js'
const PATH = '/user/route'

// 获取所有地理信息
export const getGeographyList = () => request.get(PATH + '/getGeographyAll')

// 获取路线列表
export const getRouteList = ({ page, pageSize, geographyId, userId }) =>
  request.get(PATH + '/page', {
    params: {
      page,
      pageSize,
      geographyId,
      userId
    }
  })

// 新增路线信息
export const addRoute = (data) => request.post(PATH + '/add', data)

// 根据id获取路线信息
export const getRouteById = ({ id }) =>
  request.get(PATH + '/getRouteById', { params: { id } })

// 增加访问量
export const addRouteViews = ({ id, views }) =>
  request.put(PATH + `/addRouteViews/${id}/${views}`)

// 查询是否点赞
export const isPraise = ({ routeId, userId }) =>
  request.get(PATH + '/isPraise', {
    params: {
      routeId,
      userId
    }
  })

// 点赞
export const updatePraise = (data) => request.put(PATH + '/updatePraise', data)

// 修改线路信息
export const updateRoute = (data) => request.put(PATH + '/update', data)

// 删除线路信息
export const deleteById = (id) =>
  request.delete(PATH + '/deleteByIds', { params: { ids: id.join(',') } })

// 查询用户路线点赞信息
export const getRoutePraiseList = ({ page, pageSize, userId }) =>
  request.get(PATH + '/pageQueryRoutePraise', {
    params: {
      page,
      pageSize,
      userId
    }
  })
